import React from 'react'
import BaseController from '../../../imvc/controller'
import View from './view'
import * as actions from './actions'

export default class Controller extends BaseController {
  View = View
  actions = actions
  initialState = {
    orders: [
      {
        id: 1,
        name: 'order-1'
      },
      {
        id: 2,
        name: 'order-2'
      }
    ],
    user: {
      profile: 'avatar'
    },
    num: 3,
    phase: 'init',
  }
  componentDidMount() {
    const { store } = this
    const { TO_UPDATE_PHASE_IN_DID_MOUNT } = store.actions
    TO_UPDATE_PHASE_IN_DID_MOUNT()
  }
  handleReverse = () => {
    let { REVERSE_ORDERS } = this.store.actions
    REVERSE_ORDERS()
  }
  handleNumIncr = () => {
    const { store } = this
    const { INCR_NUM } = store.actions
    INCR_NUM()
  }
  handleGotoDetail = () => {
    const { history } = this
    history.push('/playground/lists/1')
  }
  handleXyz = () => {
    console.log('click x')
  }
}